home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 1995 November / Macworld Nov ’95.toast / Education / xModels 2D and 3D / Tutorial Examples / Tutorial 7. Intro to 3D < prev    next >
Encoding:
Text File  |  1995-06-22  |  3.9 KB  |  83 lines  |  [TEXT/X_#a]

  1. ; Tutorial 7: Intro to 3D
  2.  
  3.        animate 40 ; this file defines a 40-frame animation
  4.  
  5. ; XModels-3D is very similar to xModels-2D, except that it
  6. ; deals with three-dimensional objects instead of two-dimensional.
  7. ; In xModels-2D, there is an x-axis that crosses the screen
  8. ; horizontally from left to right and a y-axis that extends
  9. ; vertically from bottom to top.  xModels-3D has also has these,
  10. ; but it adds a third axis, called the z-axis.  Each point 
  11. ; now has three coordinates.  The origin, at the center of
  12. ; the drawing window, is the point (0,0,0).  Points with
  13. ; negative z-values lie behind the screen; points with z = 0
  14. ; lie on the screen; and points with positive z-values lie
  15. ; in front of the screen.  The z-axis is perpendicular to the
  16. ; screen and passes through the point (0,0,0).  The screen
  17. ; itself is referred to as the "xy-plane".
  18. ;
  19. ; You can use the basic objects "circle", "square" and "line"
  20. ; in xModels-3D.  These objects lie in the xy-plane but can
  21. ; now be rotated or translated out of that plane.  You can 
  22. ; have ordinary two-dimensional polygons, constructed from
  23. ; PAIRS of coordinates, just as in xModels-2D.  (Note:
  24. ; xModels-3D does NOT have filled in versions of these objects,
  25. ; such as graycircle and blackpolygon.)  You can also
  26. ; have "three-dimensional polygons."  Each vertex of a
  27. ; three-dimensional polygon has THREE coordinates.  The command
  28. ; for making a three-dimensional polygon is "polygon3D".  Here
  29. ; for example are two rectangles defined as 3D polygons:
  30.  
  31.         polygon3D  -7,-7,-22  7,-7,-22  7,-7,22 -7,-7,22  
  32.         polygon3D  -7,7,-22   7,7,-22   7,7,22  -7,7,22  
  33.  
  34. ; xModels-3D has one additional basic object, called "cube".
  35. ; This represents a 1-by-1-by-1 cube centered at the point
  36. ; (0,0,0).
  37. ;
  38. ; There are, of course, differences between transformation in
  39. ; two dimensions and transformations in three dimensions.  For
  40. ; example, the "translate" command now takes three parameters,
  41. ; and thre is a "ztranslate" command.  Transformations will
  42. ; be covered in the next Tutorial, but here is an example of
  43. ; a group of moving cubes: 
  44.  
  45.         cube scale 4 zrotate 0:180 ztranslate -20:20
  46.         cube scale 4 translate 5,5,-20:20
  47.         cube scale 4 translate 5,-5,-20:20
  48.         cube scale 4 translate -5,5,-20:20
  49.         cube scale 4 translate -5,-5,-20:20
  50.             
  51. ; The middle cube rotates about the z-axis as it moves.
  52. ; It might not be obvious, but these cubes fit nicely between
  53. ; the two rectangles defined above.  If you render this, you
  54. ; will see the cubes move forward from the back of the
  55. ; rectangles to the front.  By the end of the animation, 
  56. ; though, you won't see the cubes because they have moved
  57. ; "behind" your viewpoint.  You also won't see the front ends
  58. ; of the rectangles.  The brings us to the topic of "three-
  59. ; dimensional viewing" and the View Menu.
  60. ;
  61. ; Since the computer screen is two-dimensional, a three-
  62. ; dimensional image has to be "projected" onto the screen.
  63. ; Think of a light source casting a shadow of the objects
  64. ; onto the screen.  The View Menu controls where that light
  65. ; source is placed.  By default, it is a point source
  66. ; located at the point (0,0,20), on the z-axis twenty
  67. ; units in front of the screen.  You can use the view
  68. ; menu to move the light source to (0,0,10), (0,0,40),
  69. ; or (0,0,100).  You can also choose a "Parallel projection"
  70. ; where the light rays are parallel with each other and
  71. ; with the z-axis; this is like light from the sun, which
  72. ; is at an effectively infinite distance.
  73. ;
  74. ; You can think of projection from (0,0,20) as showing
  75. ; what you would see if your eye were at the point (0,0,20).
  76. ; (This is not entirely accurate, since then the size of
  77. ; the objects would shrink as you moved farther away; in fact,
  78. ; the image is adjusted to prevent this from happening.)
  79. ; The details of projection are beyond the scope of these
  80. ; tutorials.  But you should try out the various possible
  81. ; views on this file.
  82.